package cn.easier.activity.console.controller;

import cn.easier.activity.console.service.ActivityGuessService;
import cn.easier.club.base.dto.ResultInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 赛事竞猜
 */
@Controller
@RequestMapping("/activity/guess")
public class ActivityGuessController {

    private static final Logger logger = LoggerFactory.getLogger(ActivityGuessController.class);

    private final ActivityGuessService activityGuessService;

    public ActivityGuessController(ActivityGuessService activityGuessService) {
        this.activityGuessService = activityGuessService;
    }

    /**
     * 赛事竞猜开奖
     *
     * @param activityId 活动对象
     * @return
     */
    @PostMapping("/id/{activityId}")
    @ResponseBody
    @PreAuthorize("hasAnyRole('ROLE_USER_SUPERADMIN','ROLE_USER_ADMIN','ROLE_USER_SELF')")
    public ResultInfo getGuess(@PathVariable Integer activityId, @RequestParam(value = "type", required = false) String type) {
        ResultInfo message = activityGuessService.guessLottery(activityId, type);
        return message;
    }

}
